// 员工相关
import { post } from '@/api/http'
// 负责人
const store_staff = {
  // 负责人单选（门店权限）
  store_staff_list: {
    label: 'realname',
    keyword: 'likeRealname',
    key: 'id',
    mode: 'each',
    tag: 'staff',
    api: (data: any) => post({ url: '/staff/selectStaffByOrgId', data }),
  },
  // 负责人多选（门店权限）
  store_staff_list_multiple: {
    label: 'realname',
    keyword: 'likeRealname',
    key: 'id',
    mode: 'multiple',
    tag: 'staff',
    api: (data: any) => post({ url: '/staff/selectStaffByOrgId', data }),
  },
  // 获取门店权限下的员工
  staff_select_staff_by_orgId: {
    label: 'realnamePhone',
    keyword: 'likeRealname',
    key: 'id',
    mode: 'multiple',
    tag: 'staff',
    api: (data: any) => post({ url: '/driverScheduling/selectStaffByOrgId', data }),
  },
  // 负责人多选
  store_staff_list_multiple_phone: {
    label: 'realnamePhone',
    keyword: 'likeRealname',
    key: 'id',
    mode: 'multiple',
    tag: 'staff',
    api: (data: any) => post({ url: '/carHousekeep/selectStaffByOrgId', data }),
  },
  // 申请改派 负责人 单选
  reassignment_staff_list_multiple: {
    label: 'realname',
    keyword: 'likeRealname',
    key: 'id',
    mode: 'each',
    tag: 'staff',
    api: (data: any) => post({ url: '/carHousekeep/selectStaffByOrgId', data }),
  },
  // 查询关联门店下的所有员工
  store_staff_bysite: {
    label: 'realname',
    keyword: 'likeRealname',
    key: 'id',
    mode: 'each',
    tag: 'staff',
    api: (data: any) => post({ url: '/staff/findStaffBySite', data }),
  },
  // 获取员工的机构权限
  organ_staff_limit: {
    label: 'namePhone',
    keyword: 'keyword',
    key: 'id',
    mode: 'each',
    tag: 'staff',
    api: (data: any) => post({ url: '/staff/searchEnterpriseStaffLimit', data }),
  },
  // 同步人员（全量）
  sync_staff: {
    label: 'realname',
    keyword: 'keyword',
    key: 'id',
    mode: 'each',
    tag: 'staff',
    api: (data: any) => post({ url: '/staff/searchEnterpriseStaffLimit', data }),
  },
  // 同步人员
  sync_staff_multiple: {
    label: 'realname',
    keyword: 'keyword',
    key: 'id',
    mode: 'multiple',
    tag: 'staff',
    api: (data: any) => post({ url: '/staff/searchEnterpriseStaffLimit', data }),
  },
  sync_staff_multiple_likeRealname: {
    label: 'realname',
    keyword: 'likeRealname',
    key: 'userId',
    mode: 'multiple',
    tag: 'staff',
    api: (data: any) => post({ url: '/staff/searchEnterpriseStaffLimit', data }),
  },
  // 获取企业角色
  epList_role: {
    label: 'role',
    keyword: 'role',
    key: 'role',
    mode: 'each',
    api: (data: any) => post({ url: '/role/getEpList', data }),
  },
  // 关联工单号
  getWorkCode: {
    label: 'workCode',
    keyword: 'workCode',
    key: 'id',
    mode: 'each',
    data: {
      ifCreateCost: 1,
      pageNumber: 1,
      pageSize: 200,
    },
    api: (data: any) => post({ url: '/workOrderV5/getPageList', data }),
  },
  // 短租关联业务单号
  getShortCode: {
    label: 'codeMemberName',
    keyword: 'codeMemberNameLike',
    key: 'id',
    mode: 'each',
    api: (data: any) => post({ url: '/sOrder/getAllList', data }),
  },
  // 长租关联业务单号
  getLongCode: {
    label: 'codeMemberName',
    keyword: 'codeMemberNameLike',
    key: 'id',
    mode: 'each',
    api: (data: any) => post({ url: '/czsOrderInfo/getAllList', data }),
  },
  // 获取换车关联订单号
  all_replace_order_list: {
    label: 'orderCode',
    keyword: 'refCode',
    key: 'orderId',
    mode: 'each',
    api: (data: any) => post({ url: '/workOrderV5/getReplaceOrderNo', data }),
  },
  // 指派人多选
  assign_staff_list_multiple: {
    label: 'realnamePhone',
    keyword: 'staffName',
    key: 'id',
    mode: 'multiple',
    tag: 'staff',
    api: (data: any) => post({ url: '/carHousekeep/getWorkComplete', data }),
  },
  // 根据审批人职位选择审批人信息
  operate_staff_change: {
    label: 'realname',
    keyword: 'likeRealname',
    key: 'id',
    mode: 'each',
    data: {
      pageNumber: 1,
      pageSize: 200,
    },
    tag: 'staff',
    api: (data: any) => post({ url: '/staff/pageList', data }),
  },
  // 获取指派车管家信息
  get_car_house_keeper: {
    label: 'realname',
    keyword: 'likeRealname',
    key: 'id',
    mode: 'each',
    tag: 'staff',
    api: (data: any) => post({ url: '/carHousekeep/selectStaffByOrgId', data }),
  },
  get_car_house_keeper_multiple: {
    label: 'realname',
    keyword: 'likeRealname',
    key: 'id',
    mode: 'multiple',
    tag: 'staff',
    api: (data: any) => post({ url: '/carHousekeep/selectStaffByOrgId', data }),
  },
  // 运营成本审批人和申请人查询
  operate_staff_list: {
    label: 'realname',
    keyword: 'likeRealname',
    key: 'id',
    mode: 'each',
    tag: 'staff',
    api: (data: any) => post({ url: '/staff/searchEnterpriseStaffLimit', data }),
  },
  /** 司机排班员工 */
  driver_schedule_staff: {
    label: 'realname',
    keyword: 'likeRealname',
    key: 'id',
    mode: 'multiple',
    tag: 'staff',
    api: (data: any) => post({ url: '/driverScheduling/selectStaffByOrgId', data }),
  },
  /** ETC关联订单查询 */
  relate_ref_code: {
    label: 'refCode',
    keyword: 'refCodeLike',
    key: 'id',
    mode: 'each',
    api: (data: any) => post({ url: '/etcOrder/selectRelateRefCode', data }),
  },
  /** 操作人 */
  staff_operator: {
    label: 'realname',
    keyword: 'realnameLike',
    key: 'id',
    mode: 'each',
    tag: 'staff',
    api: (data: any) => post({ url: '/user/queryRealNameLike', data }),
  },
  /** 目标渠道账号 */
  target_channel_account: {
    label: 'sourceSubject',
    keyword: 'nameAndSubjectLike',
    key: 'id',
    mode: 'each',
    api: (data: any) => {
      return new Promise((resolve) => {
        post({ url: '/channelAccount/selectList', data }).then((res) => {
          res.result.forEach((item: any) => {
            item.sourceSubject = `${item.sourceName}-${item.subject}`
          })
          resolve(res)
        })
      })
    },
  },
  // 获取拥有机构的权限的员工
  staff_authOrg: {
    label: 'realname',
    keyword: 'likeRealname',
    key: 'id',
    mode: 'each',
    tag: 'staff',
    api: (data: any) => post({ url: '/staff/selectAuthOrgStaff', data }),
  },
  // 获取拥有机构的权限的员工(多选)
  staff_authOrg_multiple: {
    label: 'realname',
    keyword: 'likeRealname',
    key: 'id',
    mode: 'multiple',
    tag: 'staff',
    api: (data: any) => post({ url: '/staff/selectAuthOrgStaff', data }),
  },
  // 获取运营主体
  operate_subject_multiple: {
    label: 'sourceNameSubject',
    keyword: 'sourceName',
    key: 'id',
    mode: 'multiple',
    api: (data: any) =>
      post({ url: '/channelAccount/pageList', data }).then((res) => {
        res.result.data.forEach((item: any) => {
          item.sourceNameSubject = `${item.sourceName}-${item.subject}`
        })
        return res
      }),
  },
}

export default {
  ...store_staff,
}
